<template>
  <div class="top-container">
    <div class="left-box">
      <div class="icon-wrapper">
        <!-- <span class="iconfont icon-home"></span>
        <span class="iconfont icon-sami-select"></span>
        <span class="iconfont icon-full-screen"></span> -->
        <img src="../assets/title.jpg" title="点我刷新好心情" style="height: 60px;width: 200px;" @click="reload()">
      </div>
      <div class="history-wrapper">
        <span class="iconfont icon-arrow-lift" @click="back()"></span>
        <span class="iconfont icon-arrow-right"@click="go()"></span>
      </div>
    </div>
    <div class="right-box">
      <div class="el-input el-input--small el-input--prefix">
        <el-input
          @keyup.native.enter="result"
          
          placeholder="输入后按回车搜索"
          prefix-icon="el-icon-search"
          v-model="inputValue">
        </el-input>
      </div>
    </div>
  </div>
</template>

<script>
  import connect from '@/evenBus.js'
  export default {
    name: 'top',
    data() {
      return {
        inputValue:''
      }
    },
    methods:{
      result(){
        if(this.inputValue==''){
          this.$message.warning('请输入内容')
        }else{
          this.$router.push({path:`/result?q=${this.inputValue}`})
          // .catch(err=>err)
          // 自定义通信事件,inputValue作为参数
          connect.$emit('inputValue',this.inputValue)
          // this.reload()
        }
      },
      go(){
        this.$router.go(1)
      },
      back(){
        this.$router.go(-1)
      },
      reload(){
        this.$router.go(0)
      }
    }
  }
</script>

<style scoped></style>
